

// backend/server.js
import express from 'express'
import cors from 'cors'
import fs from 'fs'
import https from 'https'





// 路由模块
import dingtalkRouter from './routes/dingtalk.js'
import dashboardRouter from './routes/dashboard.js'
import douyinProjectRouter from './routes/douyin_project_analysis.js'

const app = express()

app.use(cors())
app.use(express.json())

// 注册路由模块
app.use('/api/dingtalk', dingtalkRouter)
app.use('/api/dashboard', dashboardRouter)
app.use('/api/douyin_project_analysis', douyinProjectRouter)

// ✅ HTTPS 证书加载
const options = {
    key: fs.readFileSync('./ssl/dingding.link-hope.cn251112.key'),
    cert: fs.readFileSync('./ssl/dingding.link-hope.cn251112.pem')
}

// app.listen(3000, () => {
//     console.log('Server running on http://localhost:3000')
// })

// 启动 HTTPS 服务
https.createServer(options, app).listen(3000, '0.0.0.0', () => {
    console.log('✅ HTTPS Server running at https://dingding.link-hope.cn:3000')
})